//
//  LSBottomView.m
//  LookScore
//
//  Created by wws on 2018/3/26.
//  Copyright © 2018年 ChongQingXunTiCompany. All rights reserved.
//

#import "LSBottomView.h"

@implementation LSBottomView




- (instancetype)initWithFrame:(CGRect)frame withArray:(NSArray *)dataArray withImgArray:(NSArray *)imgArray{
    
    if (self = [super initWithFrame:frame]) {
        [self addcontenView:frame withArray:dataArray withImageArray:imgArray];
    }
    return self;
}


- (void)addcontenView:(CGRect)frame withArray:(NSArray *)dataArray withImageArray:(NSArray * )imgArray{
    UIView * line = [[UIView alloc] init];
    line.backgroundColor = LSLineGrayColor;
    [self addSubview:line];
    
    line.sd_layout
    .topEqualToView(self)
    .rightEqualToView(self)
    .leftEqualToView(self)
    .heightIs(1);
    
    CGFloat wight = frame.size.width / 6;
    for (NSInteger i = 0; i < dataArray.count; i++) {
        UIButton * btn = [UIButton buttonWithType:UIButtonTypeCustom];
        [btn setTitle:dataArray[i] forState:UIControlStateNormal];
        [btn setImage:[UIImage imageNamed:imgArray[i]] forState:UIControlStateNormal];
        btn.titleLabel.font = LSFontSize11;
        [btn setTitleColor:LSTitleGrayColor3 forState:UIControlStateNormal];
        if (i < 6) {
            btn.frame = CGRectMake(i * wight, 1, wight, (frame.size.height - 1)/2);
        }else{
            
            btn.frame = CGRectMake((i - 6) * wight, frame.size.height/2 + 1, wight, (frame.size.height - 1)/2);
        }
        CGFloat imageWidth = btn.imageView.bounds.size.width;
        CGFloat labelWidth = btn.titleLabel.bounds.size.width;
        btn.imageEdgeInsets = UIEdgeInsetsMake(0, labelWidth, 0, -labelWidth);
        btn.titleEdgeInsets = UIEdgeInsetsMake(0, -imageWidth-5, 0, imageWidth);
//        UIEdgeInsetsMake(<#CGFloat top#>, <#CGFloat left#>, <#CGFloat bottom#>, <#CGFloat right#>)
        [self addSubview:btn];
       
    }
    
    
}

@end
